package com.example.education;


import org.junit.jupiter.api.Test;
import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;

public class f {
    public static void main(String[] args) {
        //方式一
        test1();

        //方式二：线程池
        test2();
    }

    @Test
    private static void test1() {
        Jedis jedis = new Jedis("127.0.0.1", 6379);
        System.out.println(jedis.ping()); //PONG
        jedis.set("hello", "world");
        String value = jedis.get("hello");
        System.out.println(value);
        jedis.close();
    }

    private static void test2() {
        JedisPool pool = new JedisPool("127.0.0.1", 6379);
        Jedis jedis = pool.getResource();
        String value = jedis.get("hello");
        System.out.println(value);
        jedis.close();
    }
}
